package com.dwxt.community.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.common.base.StatusCode;
import com.dwxt.community.service.UserActionRecordService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/cms/userAction")
@RestController
public class UserActionController {
    @Autowired
    private UserActionRecordService userActionRecordService;

    /**
     * showdoc
     *
     * @param id 必须 String 资讯ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     * @catalog 社区/用户行为
     * @title 分享
     * @method post
     * @description 资讯分享
     * @url /cms/userAction/share
     */
    @PostMapping("/share")
    public BaseResult share(String info, String id) {
        if (StringUtils.isBlank(id)||StringUtils.isBlank(info)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return userActionRecordService.share(info,id);
    }
    /**
     * showdoc
     *
     * @param id 必须 String 资讯ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     * @catalog 社区/用户行为
     * @title 分享
     * @method post
     * @description 资讯分享
     * @url /cms/userAction/hit
     **/
    @PostMapping("/hit")
    public BaseResult hit(String info, String id) {
        if (StringUtils.isBlank(id)||StringUtils.isBlank(info)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return userActionRecordService.hit(info,id);
    }
}
